<script setup lang="ts">
import useRepaymentHistory from '@/hooks/handleRepaymentHistory';
import { inject} from 'vue';
const showData: any = inject('accountInfo',{})
</script>
<template>
  <div class="h3 title">（5）贷记卡账户</div>

  <template v-for="(item, i) in showData?.R2" :key="i">
    <div class="acc-name"><span>账户{{ i + 1 }} （授信协议标识：{{item?.PD01AI04}}）</span></div>
    <table>
      <tbody>
        <tr>
          <th >发卡机构</th>
          <th >账户标识</th>
          <th >开立日期</th>
          <th colspan="2">账户授信额度</th>
          <th colspan="2">共享授信额度</th>
          <th colspan="2">币种</th>
          <th colspan="2">业务种类</th>
          <th colspan="2">担保方式</th>

        </tr>
        <tr>
          <td >{{ item?.pc_cr_tr?.PD01AD02 }} {{ item?.pc_cr_tr?.PD01AI02 }} </td>
          <td  >{{ item?.pc_cr_tr?.PD01AI03 }}</td>
          <td  >{{ item?.pc_cr_tr?.PD01AR01 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr?.PD01AJ02 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr?.PD01AJ03 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr?.PD01AD04 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr?.PD01AD03 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr?.PD01AD07 }}</td>
        </tr>
        <template 
          v-if="
            item?.pc_pda_pd_c?.PD01CD01 == '逾期'||
            item?.pc_pda_pd_c?.PD01CD01 == '正常'
          "
        >
          <tr>
            <th colspan="100">截至{{ item?.pc_pda_pd_c?.PD01CR04 }}</th>
          </tr>
          <tr>
            <th colspan="2" >账户状态</th>
            <th colspan="2" >余额</th>
            <th colspan="2" >已用额度</th>
            <th colspan="2" > 未出单的大额专项分期余额</th>
            <th colspan="2" >剩余分期期数</th>
            <th colspan="2" >最近 6 个月平均使用额度</th>
            <th  >最大使用额度</th>
          </tr>
          <tr>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CD01 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ01 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ02 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ03 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CS01 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ12 }}</td>
            <td >{{ item?.pc_pda_pd_c?.PD01CJ14 }}</td>
          </tr>
          <tr>
            <th colspan="3">账单日</th>
            <th colspan="2">本月应还款</th>
            <th colspan="2">本月实还款</th>
            <th colspan="2"> 最近一次还款日期</th>
            <th colspan="2">当前逾期期数</th>
            <th colspan="2">当前逾期总额</th>
          </tr>
          <tr>
            <td colspan="3" >{{ item?.pc_pda_pd_c?.PD01CR02 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ04 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ05 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CR03 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CS02 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ06 }}</td>
          </tr>
          <template v-if=" item?.pc_pda_pd_h?.PD01HJ01">
          <tr>
            <th colspan="100">大额专项分期信息</th>
          </tr>
            <tr>
            <th colspan="4" >大额专项分期额度</th>
            <th colspan="3" >分期额度生效日期</th>
            <th colspan="3" >分期额度到期日期</th>
            <th colspan="3" >已用分期金额</th>
          </tr>
          <tr>
            <td colspan="4">{{ item?.pc_pda_pd_h?.PD01HJ01 }}</td>
            <td colspan="3">{{ item?.pc_pda_pd_h?.PD01HR01 }}</td>
            <td colspan="3">{{ item?.pc_pda_pd_h?.PD01HR02 }}</td>
            <td colspan="3">{{ item?.pc_pda_pd_h?.PD01HJ02 }}</td>
          </tr>
          </template>
          <tr>
            <th colspan="100"> {{item?.pc_pda_pd_b?.PD01BR03}}以后的最新还款记录</th>
          </tr>
          <tr>
            <th colspan="3" >余额</th>
            <th colspan="4" >还款日期</th>
            <th colspan="3" >还款金额</th>
            <th colspan="3" >当前还款状态</th>
          </tr>
          <tr>
            <td colspan="3" >{{ item?.pc_pda_pd_b?.PD01BJ01 }}</td>
            <td colspan="4" >{{ item?.pc_pda_pd_b?.PD01BR02 }}</td>
            <td colspan="3" >{{ item?.pc_pda_pd_b?.PD01BJ02 }}</td>
            <td colspan="3" >{{ item?.pc_pda_pd_b?.PD01BD04 }}</td>
          </tr>
        </template>

        <template v-else-if="
          item?.pc_pda_pd_b?.PD01BD01 == '呆账'||
          item?.pc_pda_pd_b?.PD01BD01 == '冻结'||
          item?.pc_pda_pd_b?.PD01BD01 == '止付款'||
          item?.pc_pda_pd_b?.PD01BD01 == '银行止付'||
          item?.pc_pda_pd_b?.PD01BD01 == '司法追偿'
          "
        >
        <tr>
            <th colspan="100">截至{{ item?.pc_pda_pd_b?.PD01BR03 }}</th>
          </tr>
          <tr>
            <th colspan="4">账户状态</th>
            <th colspan="4">余额</th>
            <th colspan="5">最近一次还款日期</th>
          </tr>
          <tr>
            <td colspan="4"> {{ item?.pc_pda_pd_b?.PD01BD01 }}</td>
            <td colspan="4">{{ item?.pc_pda_pd_b?.PD01BJ01 }}</td>
            <td colspan="5">{{ item?.pc_pda_pd_b?.PD01BJ02 }}</td>
          </tr>
        </template>
        <template v-else-if="
          item?.pc_pda_pd_b?.PD01BD01 == '销户'
          "
        >
        <tr>
            <th colspan="100">截至{{ item?.pc_pda_pd_b?.PD01BR03 }}</th>
          </tr>
          <tr>
            <th colspan="6">账户状态</th>
            <th colspan="7">销户日期</th>
          </tr>
          <tr>
            <td colspan="6"> {{ item?.pc_pda_pd_b?.PD01BD01 }}</td>
            <td colspan="7">{{ item?.pc_pda_pd_b?.PD01BR01 }}</td>
          </tr>
        </template>
    
        <template v-if="item?.pc_pda_pd_e">
          <tr>
            <th colspan="100">近5年的还款记录</th>
          </tr>
          <tr>
            <th>年份</th>
            <th>1月</th>
            <th>2月</th>
            <th>3月</th>
            <th>4月</th>
            <th>5月</th>
            <th>6月</th>
            <th>7月</th>
            <th>8月</th>
            <th>9月</th>
            <th>10月</th>
            <th>11月</th>
            <th>12月</th>
          </tr>
          <template v-for="(p, l) in useRepaymentHistory(item?.pc_pda_pd_e||[])" :key="l">
            <tr >
              <template v-for="(k,j) in p" :key="j">
                <td v-if="j==0"  rowspan="2">{{ k }}</td>
                <td v-else  >{{ k?.PD01ED01||'-' }}</td>
              </template>
            </tr>
            <tr>
              <template v-for="(k,m) in p" :key="m">
                <td  v-if="m!=0"  >{{ k?.PD01EJ01||'-' }}</td>
              </template>
            </tr>
          </template>
          
        </template>

        <template v-if="item?.pc_pda_pd_b?.PD01BD01 != '未激活'">
          <tr>
          <th colspan="2">特殊交易类型</th>
          <th colspan="3">发生日期</th>
          <th colspan="3">变更月数</th>
          <th colspan="2">发生金额</th>
          <th colspan="3">明细记录</th>
        </tr>
        <tr v-for="(af, j) in  item?.pc_cr_tr?.PDAF" :key="j">
          <td colspan="2">{{ af?.PD01FD01 }}</td>
          <td colspan="3">{{ af?.PD01FR01 }}</td>
          <td colspan="3">{{ af?.PD01FS02 }}</td>
          <td colspan="2">{{ af?.PD01FJ01 }}</td>
          <td colspan="3">{{ af?.PD01FQ01 }}</td>
        </tr>
        </template>
        <tr v-if="item?.pc_pda_pd_b?.PD01BD01 == '未激活'">
          <th colspan="100" >截至（{{item?.pc_pda_pd_b?.PD01BR03}}），账户状态为“{{item?.pc_pda_pd_b?.PD01BD01}}”。 </th>
        </tr>
      </tbody>
    </table>
  </template>

  <div class="h3 title">（6）准贷记卡账户</div>
  <div v-for="(item, i) in showData?.R3" :key="i">
    <div class="acc-name"><span>账户{{ i + 1 }} (授信协议标识：{{ item?.pc_cr_tr.PD01AI04 }})</span></div>
    <table>
      <tbody>
        <tr>
          <th colspan="1" >发卡机构</th>
          <th colspan="2" >账户标识</th>
          <th colspan="2" >开立日期</th>
          <th colspan="2" >账户授信额度</th>
          <th colspan="2" >共享授信额度</th>
          <th colspan="2" >币种</th>
          <th colspan="2" >担保方式</th>
        </tr>
        <tr>
          <td colspan="1" >{{ item?.pc_cr_tr.PD01AD02 }} {{ item?.pc_cr_tr.PD01AI02 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AI03 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AR01 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AJ02 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AJ03 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AD04 }}</td>
          <td colspan="2" >{{ item?.pc_cr_tr.PD01AD07 }}</td>
        </tr>
       
        <template 
          v-if="
            item?.pc_pda_pd_b?.PD01BD01 == '销户'
          "
        >
          <tr>
            <th colspan="100">截至 {{ item?.pc_pda_pd_b?.PD01BR03 }}</th>
          </tr>  
          <tr>
            <th colspan="6">账户状态</th>
            <th  colspan="7">销户日期</th>
          </tr>
          <tr>
            <td  colspan="6">{{ item?.pc_pda_pd_b?.PD01BD01 }}</td>
            <td  colspan="7">{{ item?.pc_pda_pd_b?.PD01BR01 }}</td>
          </tr>
        </template>
        <template v-else-if="item?.pc_pda_pd_b?.PD01BD01 == '呆账' ">
          <tr>
            <th colspan="100">截至 {{ item?.pc_pda_pd_b?.PD01BR03 }}</th>
          </tr>  
          <tr>
            <th colspan="4">账户状态</th>
            <th colspan="4">余额</th>
            <th colspan="5">最近一次还款日期</th>
          </tr>
          <tr>
            <td colspan="4">{{ item?.pc_pda_pd_b?.PD01BD01 }}</td>
            <td colspan="4">{{ item?.pc_pda_pd_b?.PD01BJ01 }}</td>
            <td colspan="5">{{ item?.pc_pda_pd_b?.PD01BJ02 }}</td>

          </tr>
        </template>

        <template v-if="item?.pc_pda_pd_c?.PD01CD01 == '逾期' || item?.pc_pda_pd_c?.PD01CD01 == '正常' ">
          <tr>
            <th colspan="100">截至{{ item?.pc_pda_pd_c?.PD01CR04 }}</th>
          </tr>
          <tr>
            <th colspan="1" >账户状态</th>
            <th colspan="1" >透支余额</th>
            <th colspan="1" >最近 6 个月平均透支余额</th>
            <th colspan="2" >最大透支余额</th>
            <th colspan="2" >账单日</th>
            <th colspan="2" >本月实还款</th>
            <th colspan="2" >最近一次还款日期</th>
            <th colspan="2" >透支 180 天以上未付余额</th>
          </tr>
          <tr>
            <td colspan="1" >{{ item?.pc_pda_pd_c?.PD01CD01 }}</td>
            <td colspan="1" >{{ item?.pc_pda_pd_c?.PD01CJ15 }}</td>
            <td colspan="1" >{{ item?.pc_pda_pd_c?.PD01CJ13 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ15 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CR02 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ05 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CR03 }}</td>
            <td colspan="2" >{{ item?.pc_pda_pd_c?.PD01CJ11 }}</td>
          </tr>
        </template>
       
        <template v-if="item?.pc_pda_pd_e">
          <tr>
            <th colspan="100">近5年的还款记录</th>
          </tr>
          <tr>
            <th>年份</th>
            <th>1月</th>
            <th>2月</th>
            <th>3月</th>
            <th>4月</th>
            <th>5月</th>
            <th>6月</th>
            <th>7月</th>
            <th>8月</th>
            <th>9月</th>
            <th>10月</th>
            <th>11月</th>
            <th>12月</th>
          </tr>
          <template v-for="(p, l) in useRepaymentHistory(item?.pc_pda_pd_e||[])" :key="l">
            <tr >
              <template v-for="(k,j) in p" :key="j">
                <td v-if="j==0"  rowspan="2">{{ k }}</td>
                <td v-else  >{{ k?.PD01ED01||'-' }}</td>
              </template>
            </tr>
            <tr>
              <template v-for="(k,m) in p" :key="m">
                <td  v-if="m!=0"  >{{ k?.PD01EJ01||'-' }}</td>
              </template>
            </tr>
          </template>
          
        </template>
        <tr>
          <th colspan="2">特殊交易类型</th>
          <th colspan="2">发生日期</th>
          <th colspan="3">变更月数</th>
          <th colspan="3">发生金额</th>
          <th colspan="3">明细记录</th>
        </tr>
        <tr>
          <template v-for="pd in item?.pc_cr_tr?.PDAF" :key="item.PD01FD01">
            <td colspan="2">{{ pd?.PD01FD01 }}</td>
          <td colspan="2">{{ pd?.PD01FR01 }}</td>
          <td colspan="3">{{ pd?.PD01FS02 }}</td>
          <td colspan="3">{{ pd?.PD01FJ01 }}</td>
          <td colspan="3">{{ pd?.PD01FQ01 }}</td>
          </template>
        </tr>
      </tbody>
    </table>
  </div>

</template>
<style scoped>
.acc-name {
  width: 80%;
  margin: 0 auto;
}
</style>